package com.dk.service.impl;

import com.dk.VO.TbsubscribepassVO;
import com.dk.mapper.SubscribePassMapper;
import com.dk.pojo.Tbsubscribepass;
import com.dk.service.SubscribeService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.PreDestroy;
import java.util.List;

@Service
public class Subscribeimpl implements SubscribeService {
    @Autowired
    private SubscribePassMapper subscribePassMapper;
    @Override
    public List<Tbsubscribepass> getAll() {
        List<Tbsubscribepass> list = subscribePassMapper.selectList(null);
        return list;
    }

    @Override
    public TbsubscribepassVO getById(Long id) {
        Tbsubscribepass byId = subscribePassMapper.selectById(id);
        TbsubscribepassVO vo = new TbsubscribepassVO();
        BeanUtils.copyProperties(byId, vo);
        return vo;
    }

    @Override
    public void insert(TbsubscribepassVO vo) {
        Tbsubscribepass tbsubscribepass = new Tbsubscribepass();
        BeanUtils.copyProperties(vo,tbsubscribepass);
        subscribePassMapper.insert(tbsubscribepass);
    }

    @Override
    public void deleteById(Long id) {
        subscribePassMapper.deleteById(id);
    }

    @Override
    public void update(TbsubscribepassVO vo) {
        Tbsubscribepass tbsubscribepass = new Tbsubscribepass();
        BeanUtils.copyProperties(vo,tbsubscribepass);
        subscribePassMapper.updateById(tbsubscribepass);
    }
}
